home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / srch17.exe / SRCH.DOC < prev    next >
Text File  |  1992-02-24  |  10KB  |  227 lines

  1.  
  2. Greetings!
  3.  
  4. SRCH (a shortened version of SEARCH) is a little program I wrote a few 
  5. years back that has slowly become a sort of company standard where I work.
  6. For network administrators, it's a must-have.
  7.  
  8. I had originally planned to sell SRCH as shareware, and later decided that
  9. the world has enough dinky little programs selling for a nickel, and 
  10. supported by those that don't have time for support.  SRCH is freeware;
  11. please pass a copy to anyone you feel can handle it.  Likewise, excuse the
  12. haphazard format of this doc; it looks like it was thrown together in a 
  13. night...because it was.  What do you want for free?
  14.  
  15. GREAT STUFF SRCH CAN DO FOR NETWORK ADMINISTRATORS & POWER USERS
  16. ----------------------------------------------------------------
  17. - Report total disk usage by subdirectory tree (for user home dir's)
  18. - Locate lost files in a huge tree quickly, using multiple wild card spec's
  19. - Copy or remove entire directory trees from the command line
  20. - Search and destroy zero-byte files, outdated files, etc.
  21. - Hate to say this, but "and much more!"
  22. Really, you gotta read this whole thing to understand.
  23.  
  24. POSSIBLY DANGEROUS STUFF SRCH CAN DO
  25. ------------------------------------
  26. Please, please, please, read this entire document before you attempt to
  27. use the /RM and /RT options.  SRCH can and will destroy entire subdirectory
  28. trees...it was written for people who hate "Are you sure?" prompts, so it
  29. has none.  It'll kill system files, read-only files, it doesn't care.
  30. You're holding a loaded gun...make sure you know how to use it.  Thing is,
  31. many net admin's wish they had loaded guns nowadays <grin>.
  32.  
  33.  
  34.  
  35. HOW DOES SRCH WORK?
  36. -------------------
  37. In short, it works by using a set of "filters" to select a particular set of
  38. files, then applies any one or more of the "actions" on those files.  So you
  39. just give it a path to start in (it's recursive by default, though you can
  40. specify non-recursive mode), an optional filter or filters, and an optional
  41. action.  If you give it no action, it just prints the filenames that it
  42. found meeting the filter conditions specified.
  43.  
  44. It's actually easiest to understand through examples:
  45.  
  46. SRCH
  47. displays all filenames in the current dir and all subdir's
  48.  
  49. SRCH D:\
  50. displays all filenames on the entire D: drive
  51.  
  52. SRCH F:\ /n *.bat
  53. name search: displays names of all batch files on F: drive
  54.  
  55. SRCH F:\ /n *.exe,*.com,*.bat
  56. name search: displays all program files on the F: drive
  57.  
  58. SRCH F:\UTILS /!n *.exe,*.com,*.bat
  59. not name search: displays all non-program files in my UTILS directory.
  60.  
  61. SRCH F:\UTILS /n *.exe,*.com,*.bat /!n a*.*,b*.*,c*.*
  62. displays all program files in UTILS that don't start with A, B, or C.
  63.  
  64. SRCH F:\DOCS /n *.bak /ag 3
  65. displays all backup files in my DOCS directory that are >3 days old
  66. (/ag is Age Greater; there's also an Age Less and Age Equal)
  67.  
  68. SRCH F:\DOCS /al 1
  69. displays all files in DOCS directory that were created today.
  70. (Age Less than one day)
  71.  
  72. SRCH F:\COMMON /sg 500000
  73. displays all backup filenames in \COMMON with a Size Greater than 500000
  74. (there's also a Size Less and Size Equal)
  75.  
  76. SRCH F:\ /se 0 /rm
  77. Locate all zero-byte files on my entire F: drive and remove them.
  78. WARNING: the /rm option assumes that you mean it!  As long as you have
  79. network permissions (if applicable) to remove those files, they will be
  80. removed, regardless of file attributes: INCLUDING system files in root of
  81. your boot drive!  Beginning users are advised to first execute the SRCH with
  82. no /rm option, examine the resulting list of files that are to be affected,
  83. and then re-execute the same command with /rm.
  84.  
  85. SRCH F:\OLDFILES /rt
  86. Remove tree: the \OLDFILES directory, and all subdir's, are removed.
  87. NOTE: the warning above for /rm option applies for /rt as well.
  88.  
  89. SRCH F:\OLDFILES /rt /q
  90. Quiet option: same as above, but don't display filenames as you delete them.
  91.  
  92. SRCH F:\HOME /t
  93. Display only the Total number of files, dir's, and bytes occupied in the
  94. directories under \HOME.
  95.  
  96. SRCH F:\HOME /td
  97. Display Totals by Directory for all of the subdir's under \HOME
  98. Rough example:
  99. \HOME\SCOTT                 128 files    3051k   421k  (82%)
  100. \HOME\SCOTT\DOCS             12 files     112k   128k  (96%)
  101. \HOME\SCOTT\C                 0 files       0k     0k (100%)
  102. \HOME\SCOTT\C\SRC           217 files     243k   292k  (92%)
  103. etc
  104.  
  105. The first file size is the actual number of data bytes in the files, the
  106. second is actual disk space consumed (taking cluster slop into account), and
  107. the percentage is the percentage of #1 over #2 (note that I don't have a
  108. calculator handy, so I just dreamed up the numbers above).
  109.  
  110. SRCH F:\HOME /td1
  111. Display totals by directory, only one level deep (you can specify any
  112. number), adding up everything underneath...this is REAL nice for doing the
  113. following on a network:
  114. \HOME\MICKEY                          551 files:  12728k  14184k (89%)
  115. \HOME\SCOTT                            21 files:    997k   1056k (94%)
  116. \HOME\BOB                              50 files:   3588k   3719k (96%)
  117. \HOME\JERRY                           112 files:   1651k   1888k (87%)
  118. \HOME\PHIL                            462 files:   6439k   7467k (86%)
  119.  
  120. Now we know who the disk pigs are.
  121.  
  122.  
  123. Let's get to a couple tricky ones...
  124.  
  125. SRCH F:\HOME\SCOTT\EXPORT /c F:\HOME\JERRY\IMPORT
  126. Copy Scott's export directory to Jerry's import directory, with the entire
  127. subdirectory tree intact.  In other words, as the source directories are 
  128. recursed, the destination directories are created to mirror those on the
  129. source.
  130.  
  131. SRCH F:\HOME\SCOTT\EXPORT /f F:\HOME\JERRY\IMPORT
  132. Flat file copy: copy all files under Scott's export tree over to Jerry's
  133. import directory, but don't create any subdir's on Jerry's side.
  134. The "flat" means that even though the source may be a tree several levels
  135. deep, the destination directory is never changed...meaning that all of
  136. the files from the source are copied into a single directory on the 
  137. destination drive.  Note that this has strange consequences when there
  138. exist many files on the source with the same name.
  139.  
  140. SRCH F:\HOME\SCOTT\EXPORT /nr /c F:\HOME\JERRY\IMPORT
  141. Non-recursive copy: this command is equivalent to
  142. COPY \HOME\SCOTT\EXPORT\*.* \HOME\JERRY\IMPORT
  143. In other words, recursion on the source directory is turned off; SRCH only
  144. acts on the files in the top directory specified as the source.
  145.  
  146. SRCH C:\MYDOCS /b F:\HOME\SCOTT\HDBACKUP
  147. Backup (copy files that have archive bit set, reset archive bit) my
  148. documents on my C: drive into a directory on my F: drive.
  149.  
  150. SRCH C:\MYDOCS /?a /c F:\HOME\SCOTT\HDBACKUP /-a
  151. This command uses a SRCH by file attribute (archive bit, in this case) to do
  152. exactly the same as the previous example.  Note you can also SRCH for files
  153. that DON'T have a particular attribute set, and you can manipulate them as
  154. well.
  155.  
  156.  
  157. There's more, but I'm tired of typing and you're tired of reading.  Here's a
  158. grand finale (make things real ugly)
  159.  
  160. SRCH C:\ /nr /?h!a /!n *.sys /ag 30 /c F:\BADFILES /rm
  161. Locate files in root of C: (not subdir's) that are hidden but have archive
  162. bit cleared, don't have a .SYS extension, and are more than a month old.
  163. Copy those to a dir on F: and then remove the ones on C:.  <gasp, pant pant>
  164.  
  165.  
  166. FUTURE PLANS FOR SRCH (AND KNOWN PROBLEMS TO FIX!)
  167. --------------------------------------------------
  168. SRCH has a few drawbacks that I'll fix when I have the time.  I'm in the 
  169. process of rewriting it entirely, and expect that the next release will be
  170. v2.0.  I need some feedback and/or encouragement, though.  Send me your 
  171. thoughts, good or bad!
  172.  
  173. The biggest problem now is that SRCH's return values are nearly worthless.
  174. Batch file use is limited because you can't tell if an operation succeeded
  175. or not using error levels.  That will be fixed.
  176.  
  177. Often SRCH output scrolls forever, and the user has to pipe the output into
  178. MORE to be able to read it.  I plan to add a /P option to PAUSE the output
  179. after each screenful...and do it right whether you're in 25, 43, or 50, or
  180. whatever line mode.
  181.  
  182. When you pass a non-existent directory name to SRCH, you get "No matching
  183. files found", just like the dir did exist and there really were no files
  184. there.  Later versions will instead report "directory does not exist", to 
  185. avoid disasters caused by typing errors.
  186.  
  187. Some people have really wiped themselves out by accidentally removing the
  188. system files (and all else) from their boot disk with a typing error.
  189. Some have suggested that /RM prompt for verification of deletion of each
  190. file, with /RM! to delete no matter what (same for /RT and /RT!).  I'm 
  191. waiting for more input before I decide to do this...it's contrary to what 
  192. I wrote it for.  In fact, /RM used to be just /R until I realized how
  193. close that was to /F and /T on the keyboard.
  194.  
  195. I'd like to add a /M for MOVE option, that will remove the source file
  196. only if it was successfully copied to the destination tree.  Today, the
  197. copy and remove functions are totally separate, which could be dangerous
  198. if you run out of space on the destination drive before the copy is 
  199. completed... the /RM continues even after the /C fails.
  200.  
  201. Last, I want to add a rather confusing filter that is based on the
  202. existence of a file on the destination drive.  In other words, to copy
  203. only those files that already exist on the destination (in effect updating
  204. a directory) you'd type SRCH C:\NEWVER /E /C D:\OUTDATED.  You could also
  205. use this filter with a negation to remove any files in one tree that didn't
  206. exist on a source (this is handy where a tree is regularly updated with
  207. SRCH, but sometimes files are deleted on the source and left lying around
  208. on the destination)...
  209.  
  210. SRCH C:\SRC /C D:\DEST         copy all files into existing DEST directory
  211. SRCH D:\DEST /!E C:\SRC /RM    then remove those in DEST that aren't on SOURCE
  212.  
  213.  
  214.  
  215. CONTACTING ME
  216. -------------
  217. I love hearing comments about my programs, which are always distributed as
  218. freeware (so far, anyways).  What I don't like is getting telephone calls in 
  219. the middle of the night when my kids are in bed.  Please, direct your messages
  220. via eMail (preferred: as of this writing I'm on CompuServe nearly every day)
  221. or US Mail.  Comments welcomed when addressed to:
  222.  
  223. Scott Wertz                  CompuServe:  71541,3051
  224. 9740 Michael Drive             MHS Mail:  SW @ RRC
  225. Streetsboro, OH  44241
  226.  
  227.